package com.accp.jboa.biz;

import com.accp.jboa.dao.CheckMapper;
import com.accp.jboa.dao.ReimburseMapper;
import com.accp.jboa.pojo.Check;
import com.accp.jboa.pojo.Employee;
import com.accp.jboa.pojo.Leave;
import com.accp.jboa.pojo.Reimburse;
import com.accp.jboa.vo.EmployeeAndLeaveAndCheckVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;

@Service
public class Checkbiz {

    @Autowired(required = false)
    private CheckMapper checkMapper;

    @Autowired(required = false)
    private Leavebiz leavebiz;

    @Autowired(required = false)
    private ReimburseMapper reimburseMapper;


    public int update(Check check) {
        Leave leave = new Leave();
        leave.setStatusid(check.getStatusid());
        leave.setLeaveid(check.getBizid());
        leave.setNextdealman(check.getNextdealman());
        leavebiz.updateLeave(leave);
        return checkMapper.updateByPrimaryKeySelective(check);
    }

    public Check insertCeck(Check check) {
        checkMapper.insert(check);
        return check;
    }

    public EmployeeAndLeaveAndCheckVo querynextdealman(int id,Integer checkid) {
        return checkMapper.querynextdealman(id);
    }

    public String querynextdealman(int id) {
        return checkMapper.querynextdealmans(id);
    }

    public int insert(Check check) {
        check.setCheckid(null);
        Leave leave = new Leave();
        leave.setStatusid(check.getStatusid());
        leave.setLeaveid(check.getBizid());
        leave.setNextdealman(check.getNextdealman());
        leavebiz.updateLeave(leave);
        return checkMapper.insertSelective(check);
    }

    public int insertCheck(Check check) {
        check.setCheckid(null);
        Reimburse reimburse = new Reimburse();
        reimburse.setStatusid(check.getStatusid());
        reimburse.setReimburseid(check.getBizid());
        reimburse.setNextdealman(check.getNextdealman());
        reimburseMapper.updateByPrimaryKeySelective(reimburse);
        return checkMapper.insertSelective(check);
    }
}
